﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Text;
using System.IO;
using System.Xml;
using System.Data;
using Gift.WebApp;
using System.Collections;

using Gift.DAL;
using Gift.Model;


public partial class cn_order_info : BasePage
{
    // Fields



    protected string postscriptXmlPath = "/cn/xml/order_postscript.xml";
    protected string xmlPath = "/cn/xml/payment.xml";

    // Methods
    protected StringBuilder DeliveryWayBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            if (base.LoginUserMember == null)
            {
                return builder;
            }
            builder.AppendLine("<h6>配送方式：</h6>");
            builder.AppendLine("<table class=\"secondtable\">");
            DataTable shoppingCartByUser = BaseFactory.theShoppingCart.GetShoppingCartByUser(base.LoginUserMember.MemberId);
            int num = 0;
            decimal num2 = 0M;
            int freightTemplate = 0;
            string item = "";
            if (base.LoginUserMember.IsCard == false)
            {
                DataTable defaultUserAddressByUser = BaseFactory.theUserAddress.GetDefaultUserAddressByUser(base.LoginUserMember.ClientUser.id);
                if (defaultUserAddressByUser.Rows.Count > 0)
                {
                    item = defaultUserAddressByUser.Rows[0]["region"].ToString().Split(new char[] { ',' }).GetValue(0).ToString();
                }
                else
                {
                    DataTable userAddressByUser = BaseFactory.theUserAddress.GetUserAddressByUser(base.LoginUserMember.ClientUser.id);
                    if (userAddressByUser.Rows.Count > 0)
                    {
                        item = userAddressByUser.Rows[0]["region"].ToString().Split(new char[] { ',' }).GetValue(0).ToString();
                    }
                }
            }
            foreach (DataRow row in shoppingCartByUser.Rows)
            {
                num += Convert.ToInt32(row["amount"]);
                if (Convert.ToInt32(row["isFromFreight"]) == 0)
                {
                    DataTable table4 = BaseFactory.theFreightWay.GetFreightWayByFreightTemplate(Convert.ToInt32(row["freightTemplate"]));
                    ArrayList list = new ArrayList();
                    foreach (DataRow row2 in table4.Rows)
                    {
                        if ((ArrayList.Adapter(row2["region"].ToString().Split(new char[] { ',' })).Contains(item) && !list.Contains(row2["deliveryWayId"].ToString())) && (Convert.ToDecimal(row2["defaultFreight"]) > num2))
                        {
                            num2 = Convert.ToDecimal(row2["defaultFreight"]);
                            freightTemplate = Convert.ToInt32(row["freightTemplate"]);
                        }
                    }
                    foreach (DataRow row2 in table4.Rows)
                    {
                        if (((row2["region"].ToString() == "0") && !list.Contains(row2["deliveryWayId"].ToString())) && (Convert.ToDecimal(row2["defaultFreight"]) > num2))
                        {
                            num2 = Convert.ToDecimal(row2["defaultFreight"]);
                            freightTemplate = Convert.ToInt32(row["freightTemplate"]);
                        }
                    }
                }
            }
            DataTable freightWayByFreightTemplate = BaseFactory.theFreightWay.GetFreightWayByFreightTemplate(freightTemplate);
            ArrayList list3 = new ArrayList();
            if (freightWayByFreightTemplate.Rows.Count > 0)
            {
                foreach (DataRow row2 in freightWayByFreightTemplate.Rows)
                {
                    bool flag = false;
                    decimal num4 = 0M;
                    ArrayList list4 = new ArrayList();
                    foreach (DataRow row in shoppingCartByUser.Rows)
                    {
                        if (Convert.ToInt32(row["isFromFreight"]) == 0)
                        {
                            DataTable table6 = BaseFactory.theFreightWay.GetFreightWayByFreightTemplate(Convert.ToInt32(row["freightTemplate"]));
                            foreach (DataRow row3 in table6.Rows)
                            {
                                if (Convert.ToInt32(row3["deliveryWayId"]) == Convert.ToInt32(row2["deliveryWayId"]))
                                {
                                    if ((ArrayList.Adapter(row3["region"].ToString().Split(new char[] { ',' })).Contains(item) && !list3.Contains(row2["deliveryWayId"].ToString())) && !list4.Contains(Convert.ToInt32(row["geid"])))
                                    {
                                        if (Convert.ToInt32(row3["freightTemplateId"]) == Convert.ToInt32(row2["freightTemplateId"]))
                                        {
                                            if (flag)
                                            {
                                                num4 += Convert.ToDecimal(row3["increasedFreight"]) * Convert.ToInt32(row["amount"]);
                                            }
                                            else
                                            {
                                                num4 += Convert.ToDecimal(row3["defaultFreight"]) + (Convert.ToDecimal(row3["increasedFreight"]) * (Convert.ToInt32(row["amount"]) - 1));
                                                flag = true;
                                            }
                                        }
                                        else
                                        {
                                            num4 += Convert.ToDecimal(row3["increasedFreight"]) * Convert.ToInt32(row["amount"]);
                                        }
                                        list4.Add(Convert.ToInt32(row["geid"]));
                                    }
                                    if (((row3["region"].ToString() == "0") && !list3.Contains(row2["deliveryWayId"].ToString())) && !list4.Contains(Convert.ToInt32(row["geid"])))
                                    {
                                        if (Convert.ToInt32(row3["freightTemplateId"]) == Convert.ToInt32(row2["freightTemplateId"]))
                                        {
                                            if (flag)
                                            {
                                                num4 += Convert.ToDecimal(row3["increasedFreight"]) * Convert.ToInt32(row["amount"]);
                                            }
                                            else
                                            {
                                                num4 += Convert.ToDecimal(row3["defaultFreight"]) + (Convert.ToDecimal(row3["increasedFreight"]) * (Convert.ToInt32(row["amount"]) - 1));
                                                flag = true;
                                            }
                                        }
                                        else
                                        {
                                            num4 += Convert.ToDecimal(row3["increasedFreight"]) * Convert.ToInt32(row["amount"]);
                                        }
                                        list4.Add(Convert.ToInt32(row["geid"]));
                                    }
                                }
                            }
                        }
                    }
                    if (num4 != 0M)
                    {
                        list3.Add(row2["deliveryWayId"].ToString());
                        builder.AppendLine("<tr>");
                        builder.AppendLine(string.Concat(new object[] { "<td class=\"firsttd\"><input type=\"radio\" name=\"deliveryWay\" onclick=\"changeDeliveryWay('", num4, "');\" value=\"", row2["deliveryWay"], ",", num4, "\" />", row2["deliveryWay"], "</td>" }));
                        builder.AppendLine("<td><strong>+ " + string.Format("{0:C}", num4) + "</strong></td>");
                        builder.AppendLine("</tr>");
                    }
                }
            }
            else
            {
                builder.AppendLine("<tr>");
                builder.AppendLine("<td class=\"firsttd\"><input type=\"radio\" name=\"deliveryWay\" onclick=\"changeDeliveryWay('0');\" value=\"0,0\" />卖家承担运费 </td>");
                builder.AppendLine("<td><strong>+ 0.00</strong></td>");
                builder.AppendLine("</tr>");
            }
            builder.AppendLine("</table>");
        }
        catch
        {
        }
        return builder;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (base.LoginUserMember == null)
        {
            base.Response.Redirect("/cn/web_login.html?ru=" + HttpContext.Current.Request.Url.PathAndQuery.Replace("aspx", "html"));
        }
    
    }

    protected StringBuilder PaymentBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            string attribute = "";
            if (base.LoginUserMember == null) return builder;
            else if(base.LoginUserMember.IsCard == true)
            {
                builder.AppendLine("<tr><td>");
                if(base.LoginUserMember.DicUserCardList != null)
                foreach (tbCard oCard in base.LoginUserMember.DicUserCardList.Values)
                {
                    builder.Append(oCard.cardcode + "|");
                }
                builder.Append("</td></tr>");
                builder.Append(" <tr> "
                        + " <td> "
                            + " <input type=\"radio\" name=\"pay_bank\" checked=\"checked\" value=\"卡券支付\" />卡券支付</td>"
                    + "</tr>");
            }
            else
            {

                XmlDocument document = new XmlDocument();
                document.Load(base.Server.MapPath(this.xmlPath));
                XmlNodeList childNodes = document.SelectSingleNode("paymentMethod").ChildNodes;
                foreach (XmlNode node in childNodes)
                {
                    XmlElement element = (XmlElement)node;
                    if (element.GetAttribute("checked") == "true")
                    {
                        attribute = element.GetAttribute("id");
                        break;
                    }
                }
                switch (attribute)
                {
                    case "1":
                        builder.AppendLine("<tr>");
                        builder.AppendLine("<td colspan=\"3\"><input type=\"radio\" name=\"pay_bank\" value=\"directPay\" checked=\"checked\" /><img src=\"/cn/payment/alipay_1.gif\" alt=\"支付宝\" /></td>");
                        builder.AppendLine("</tr>");
                        builder.AppendLine("<tr>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"ICBCB2C\" /><img src=\"/cn/payment/ICBC_OUT.gif\" alt=\"中国工商银行\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"CMB\" /><img src=\"/cn/payment/CMB_OUT.gif\" alt=\"招商银行\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"CCB\" /><img src=\"/cn/payment/CCB_OUT.gif\" alt=\"中国建设银行\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"BOCB2C\" /><img src=\"/cn/payment/BOC_OUT.gif\" alt=\"中国银行\" /></td>");
                        builder.AppendLine("</tr>");
                        builder.AppendLine("<tr>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"ABC\" /><img src=\"/cn/payment/ABC_OUT.gif\" alt=\"中国农业银行\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"COMM\" /><img src=\"/cn/payment/COMM_OUT.gif\" alt=\"交通银行\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"SPDB\" /><img src=\"/cn/payment/SPDB_OUT.gif\" alt=\"浦发银行\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"GDB\" /><img src=\"/cn/payment/GDB_OUT.gif\" alt=\"广东发展银行\" /></td>");
                        builder.AppendLine("</tr>");
                        builder.AppendLine("<tr>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"CITIC\" /><img src=\"/cn/payment/CITIC_OUT.gif\" alt=\"中信银行\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"CEBBANK\" /><img src=\"/cn/payment/CEB_OUT.gif\" alt=\"中国光大银行\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"CIB\" /><img src=\"/cn/payment/CIB_OUT.gif\" alt=\"兴业银行\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"SDB\" /><img src=\"/cn/payment/SDB_OUT.gif\" alt=\"深圳发展银行\" /></td>");
                        builder.AppendLine("</tr>");
                        builder.AppendLine("<tr>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"CMBC\" /><img src=\"/cn/payment/CMBC_OUT.gif\" alt=\"中国民生银行\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"HZCBB2C\" /><img src=\"/cn/payment/HZCB_OUT.gif\" alt=\"杭州银行\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"SHBANK\" /><img src=\"/cn/payment/SHBANK_OUT.gif\" alt=\"上海银行\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"NBBANK\" /><img src=\"/cn/payment/NBBANK_OUT.gif\" alt=\"宁波银行\" /></td>");
                        builder.AppendLine("</tr>");
                        builder.AppendLine("<tr>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"SPABANK\" /><img src=\"/cn/payment/SPABANK_OUT.gif\" alt=\"平安银行\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"BJRCB\" /><img src=\"/cn/payment/BJRCB_OUT.gif\" alt=\"北京农村商业银行\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"ICBCBTB\" /><img src=\"/cn/payment/ENV_ICBC_OUT.gif\" alt=\"中国工商银行(企业)\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"CCBBTB\" /><img src=\"/cn/payment/ENV_CCB_OUT.gif\" alt=\"中国建设银行(企业)\" /></td>");
                        builder.AppendLine("</tr>");
                        builder.AppendLine("<tr>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"SPDBB2B\" /><img src=\"/cn/payment/ENV_SPDB_OUT.gif\" alt=\"浦发银行(企业)\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"ABCBTB\" /><img src=\"/cn/payment/ENV_ABC_OUT.gif\" alt=\"中国农业银行(企业)\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"fdb101\" /><img src=\"/cn/payment/FDB_OUT.gif\" alt=\"富滇银行\" /></td>");
                        builder.AppendLine("<td><input type=\"radio\" name=\"pay_bank\" value=\"PSBC-DEBIT\" /><img src=\"/cn/payment/PSBC_OUT.gif\" alt=\"中国邮政储蓄银行\" /></td>");
                        builder.AppendLine("</tr>");
                        return builder;

                    case "2":
                        builder.AppendLine("<tr>");
                        builder.AppendLine("<td colspan=\"3\"><input type=\"radio\" name=\"pay_bank\" value=\"Paypal\" checked=\"checked\" /><img src=\"/cn/payment/paypal.gif\" alt=\"Paypal\" /></td>");
                        builder.AppendLine("</tr>");
                        break;
                }
                builder.Append(" <tr> "
                            +" <td> "
                                +" <input type=\"radio\" name=\"pay_bank\" value=\"货到付款\" />货到付款</td>"
                        +"</tr>"
                        +"<tr>"
                            +"<td>"
                                +"<input type=\"radio\" name=\"pay_bank\" value=\"预存款\" />预存款</td>"
                       +" </tr>");
            }
        }
        catch
        {
        }
        return builder;
    }

    protected StringBuilder PostscriptBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.postscriptXmlPath));
            XmlElement element = document.SelectSingleNode("postscript/set") as XmlElement;
            builder.AppendLine("<h6>附言：</h6>");
            builder.AppendLine("<p><textarea id=\"txtaPostscript\" cols=\"" + element.GetAttribute("cols") + "\" rows=\"" + element.GetAttribute("rows") + "\">" + element.GetAttribute("value") + "</textarea><span id=\"spPostscript\"></span></p>");
        }
        catch
        {
        }
        return builder;
    }

    protected StringBuilder ProvincesBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            builder.AppendLine("<p><label for=\"selectProvinces\">省份/直辖市：</label>");
            builder.AppendLine("<select id=\"selectProvinces\">");
            builder.AppendLine("<option value=\"0\" selected=\"selected\">请选择...</option>");
            DataTable regionByParentRegion = BaseFactory.theRegion.GetRegionByParentRegionAndCompanyId(0, base.CompanyId);
            foreach (DataRow row in regionByParentRegion.Rows)
            {
                builder.AppendLine(string.Concat(new object[] { "<option value=\"", row["id"], "\">", row["regionName"], "</option>" }));
            }
            builder.AppendLine("</select><span id=\"spanCity\" style=\"color: #000000;\"></span><span id=\"spProvinces\">*</span></p>");
        }
        catch
        {
        }
        return builder;
    }

    protected StringBuilder ShoppingCartBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            if (base.LoginUserMember == null)
            {
                return builder;
            }
            DataTable shoppingCartByUser = BaseFactory.theShoppingCart.GetShoppingCartByUser(base.LoginUserMember.MemberId);
            if (shoppingCartByUser.Rows.Count > 0)
            {
                foreach (DataRow row in shoppingCartByUser.Rows)
                {
                    builder.AppendLine("<tr>");
                    builder.AppendLine(string.Concat(new object[] { "<td><a href=\"/cn/goods.html?id=", row["gId"], "\" target=\"_blank\">", row["goodsArtno"], "</a></td>" }));
                    DataTable goodGalleryByGoods = BaseFactory.theGoodGallery.GetGoodGalleryByGoods(Convert.ToInt32(row["gid"]));
                    builder.AppendLine(string.Concat(new object[] { "<td><a href=\"/cn/goods.html?id=", row["gId"], "\" target=\"_blank\"><img class=\"proimg\" src=\"", goodGalleryByGoods.Rows[0]["thumbImg"], "\" alt=\"", goodGalleryByGoods.Rows[0]["imgAlt"], "\" /></a></td>" }));
                    builder.AppendLine(string.Concat(new object[] { "<td><a href=\"/cn/goods.html?id=", row["gId"], "\" target=\"_blank\">", row["goodsName"], "</a>" }));
                    DataTable table3 = BaseFactory.theGoodsEntitysSpecifications.FrontDeskGetGoodsEntitysSpecificationsByGoodsEntitys(Convert.ToInt32(row["geid"]));
                    for (int i = 0; i < table3.Rows.Count; i++)
                    {
                        builder.Append(string.Concat(new object[] { (i > 0) ? "&nbsp;&nbsp;" : "", table3.Rows[i]["specificationsName"], "：", table3.Rows[i]["specificationsValueName"] }));
                    }
                    builder.AppendLine("<hr class=\"hr\"/>");
                    builder.AppendLine("<img class=\"promotion\" " + ((Convert.ToInt32(row["isOrderFromFreight"]) == 1) ? ("src=\"/script/images/seled.jpg\" alt=\"参与\"") : ("src=\"/script/images/seledb.jpg\" alt=\"不参与\"")) + "\" alt=\"参与\"/>&nbsp;满额免运费&nbsp;");
                    builder.AppendLine("<img class=\"promotion\" " + ((Convert.ToInt32(row["isDiscount"]) == 1) ? ("src=\"/script/images/seled.jpg\" alt=\"参与\"") : ("src=\"/script/images/seledb.jpg\" alt=\"不参与\"")) + "\" alt=\"参与\"/>&nbsp;满额打折&nbsp;");
                    builder.AppendLine("<img class=\"promotion\" " + ((Convert.ToInt32(row["isTotalReduce"]) == 1) ? ("src=\"/script/images/seled.jpg\" alt=\"参与\"") : ("src=\"/script/images/seledb.jpg\" alt=\"不参与\"")) + "\" alt=\"参与\"/>&nbsp;满额减少&nbsp;");
                    builder.AppendLine("<img class=\"promotion\" " + ((Convert.ToInt32(row["isGifts"]) == 1) ? ("src=\"/script/images/seled.jpg\" alt=\"参与\"") : ("src=\"/script/images/seledb.jpg\" alt=\"不参与\"")) + "\" alt=\"参与\"/>&nbsp;满额赠送礼品&nbsp;");
                    builder.AppendLine("<img class=\"promotion\" " + ((Convert.ToInt32(row["isSendIntegral"]) == 1) ? ("src=\"/script/images/seled.jpg\" alt=\"参与\"") : ("src=\"/script/images/seledb.jpg\" alt=\"不参与\"")) + "\" alt=\"参与\"/>&nbsp;满额赠送积分");
                    builder.Append("</td>");
                    builder.AppendLine("<td>" + string.Format("{0:C}", Convert.ToDecimal(row["salePrice"])) + "</td>");
                    builder.AppendLine("<td> " + row["amount"] + " </td>");
                    builder.AppendLine("<td>" + string.Format("{0:C}", Convert.ToDecimal(row["total"])) + "</td>");
                    builder.AppendLine("</tr>");
                }
                return builder;
            }
            builder.AppendLine("<tr>");
            builder.AppendLine("<td colspan=\"7\" style=\"text-align: center; color: #ff0000;\">购物车目前没有加入任何商品</td>");
            builder.AppendLine("</tr>");
        }
        catch
        {
        }
        return builder;
    }

    protected StringBuilder ShoppingCartTotalBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            if (base.LoginUserMember == null)
            {
                return builder;
            }
            int num = 0;
            int num2 = 0;
            decimal num3 = 0M;
            decimal num4 = 0M;
            decimal num5 = 0M;
            decimal num6 = 0M;
            decimal num7 = 0M;
            decimal num8 = 0M;
            decimal num9 = 0M;
            decimal num10 = 0M;
            decimal num11 = 0M;
            decimal num12 = 0M;
            decimal num13 = 0M;
            decimal num14 = 0M;
            decimal num15 = 0M;
            string str = "";
            string str2 = "false";
            DataTable shoppingCartByUser = BaseFactory.theShoppingCart.GetShoppingCartByUser(base.LoginUserMember.MemberId);
            foreach (DataRow row in shoppingCartByUser.Rows)
            {
                if (Convert.ToInt32(row["isOrderFromFreight"]) == 1)
                {
                    num4 += Convert.ToDecimal(row["total"]);
                }
                else
                {
                    num3 += Convert.ToDecimal(row["total"]);
                }
                if (Convert.ToInt32(row["isDiscount"]) == 1)
                {
                    num6 += Convert.ToDecimal(row["total"]);
                }
                else
                {
                    num5 += Convert.ToDecimal(row["total"]);
                }
                if (Convert.ToInt32(row["isTotalReduce"]) == 1)
                {
                    num8 += Convert.ToDecimal(row["total"]);
                }
                else
                {
                    num7 += Convert.ToDecimal(row["total"]);
                }
                if (Convert.ToInt32(row["isGifts"]) == 1)
                {
                    num10 += Convert.ToDecimal(row["total"]);
                }
                else
                {
                    num9 += Convert.ToDecimal(row["total"]);
                }
                if (Convert.ToInt32(row["isSendIntegral"]) == 1)
                {
                    num12 += Convert.ToDecimal(row["total"]);
                }
                else
                {
                    num += Convert.ToInt32(row["giveIntegral"]) * Convert.ToInt32(row["amount"]);
                    num11 += Convert.ToDecimal(row["total"]);
                }
                num2 += Convert.ToInt32(row["amount"]);
                num15 += Convert.ToDecimal(row["total"]);
            }
            DataTable goodsPromotion = BaseFactory.theGoodsPromotion.GetGoodsPromotion();
            foreach (DataRow row in goodsPromotion.Rows)
            {
                if (Convert.ToInt32(row["promotionType"]) == 1)
                {
                    if (((num4 >= Convert.ToDecimal(row["floorAmount"])) && (DateTime.Now >= Convert.ToDateTime(row["startTime"]))) && (DateTime.Now <= Convert.ToDateTime(row["endTime"])))
                    {
                        str = str + "<br />&nbsp;" + row["promotionTitle"].ToString();
                        str2 = "true";
                    }
                }
                else
                {
                    string str3;
                    if (Convert.ToInt32(row["promotionType"]) == 2)
                    {
                        if ((((num6 >= Convert.ToDecimal(row["floorAmount"])) && (num6 < Convert.ToDecimal(row["limitAmount"]))) && (DateTime.Now >= Convert.ToDateTime(row["startTime"]))) && (DateTime.Now <= Convert.ToDateTime(row["endTime"])))
                        {
                            num13 = num6 * (Convert.ToDecimal(1) - (Convert.ToDecimal(row["discount"]) / 100M));
                            str3 = str;
                            str = str3 + "<br />&nbsp;" + row["promotionTitle"].ToString() + "，减" + string.Format("{0:C}", num13);
                        }
                    }
                    else if (Convert.ToInt32(row["promotionType"]) == 3)
                    {
                        if ((((num8 >= Convert.ToDecimal(row["floorAmount"])) && (num8 < Convert.ToDecimal(row["limitAmount"]))) && (DateTime.Now >= Convert.ToDateTime(row["startTime"]))) && (DateTime.Now <= Convert.ToDateTime(row["endTime"])))
                        {
                            num14 = Convert.ToDecimal(row["preferentialAmount"]);
                            str3 = str;
                            str = str3 + "<br />&nbsp;" + row["promotionTitle"].ToString() + "，减" + string.Format("{0:C}", num14);
                        }
                    }
                    else if (Convert.ToInt32(row["promotionType"]) == 4)
                    {
                        if ((((num10 >= Convert.ToDecimal(row["floorAmount"])) && (num10 < Convert.ToDecimal(row["limitAmount"]))) && (DateTime.Now >= Convert.ToDateTime(row["startTime"]))) && (DateTime.Now <= Convert.ToDateTime(row["endTime"])))
                        {
                            str = str + "<br />&nbsp;" + row["promotionTitle"].ToString();
                        }
                    }
                    else if ((Convert.ToInt32(row["promotionType"]) == 5) && ((((num12 >= Convert.ToDecimal(row["floorAmount"])) && (num12 < Convert.ToDecimal(row["limitAmount"]))) && (DateTime.Now >= Convert.ToDateTime(row["startTime"]))) && (DateTime.Now <= Convert.ToDateTime(row["endTime"]))))
                    {
                        num += Convert.ToInt32(row["presentedIntegral"]);
                        if (Convert.ToInt32(row["isOverlap"]) == 1)
                        {
                            foreach (DataRow row2 in shoppingCartByUser.Rows)
                            {
                                if (Convert.ToInt32(row2["isSendIntegral"]) == 1)
                                {
                                    num += Convert.ToInt32(row2["giveIntegral"]) * Convert.ToInt32(row2["amount"]);
                                }
                            }
                        }
                        str = str + "<br />&nbsp;" + row["promotionTitle"].ToString();
                    }
                }
            }
            num15 = (num15 - num13) - num14;
            builder.AppendLine(string.Concat(new object[] { "<p id=\"pTotal\"><span>商品数量总计：<strong>", num2, "</strong>件</span><span>赠送积分总计：<strong>", num, "</strong>分</span><span>商品金额总数：<strong id=\"sSumGoods\">", string.Format("{0:C}", num15), "</strong></span><span>运费：<strong id=\"sSumFreight\">￥0.00</strong></span></p>" }));
            builder.AppendLine("<p><span><strong>" + ((str != "") ? "参加促销活动：" : "") + str + "</strong></span></p>");
            builder.AppendLine("<p class=\"textright\"><strong id=\"sSumTotal\">您共需要为订单支付：" + string.Format("{0:C}", num15) + "</strong></p>");
            builder.AppendLine("<input id=\"hdGoodsSum\" type=\"hidden\" value=\"" + num15 + "\" />");
            builder.AppendLine("<input id=\"hdFromFreight\" type=\"hidden\" value=\"" + str2 + "\" />");
        }
        catch
        {
        }
        return builder;
    }

    protected StringBuilder UserAddressBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            if (base.LoginUserMember == null)
            {
                return builder;
            }
            if (base.LoginUserMember.IsCard == false)
            {
                builder.AppendLine("<table class=\"firsttable\">");

                DataTable userAddressByUser = BaseFactory.theUserAddress.GetUserAddressByUser(base.LoginUserMember.ClientUser.id);
                foreach (DataRow row in userAddressByUser.Rows)
                {
                    builder.AppendLine("<tr>");
                    builder.AppendLine(string.Concat(new object[] { "<td><input type=\"radio\" name=\"userAddress\" value=\"", row["id"], "\" onclick=\"isDisplayUserAddress('", row["region"].ToString().Split(new char[] { ',' }).GetValue(0), "');\" ", (Convert.ToInt32(row["isDefault"]) == 1) ? "checked='checked'" : "", " />", row["consignee"], "</td>" }));
                    builder.AppendLine(string.Concat(new object[] { "<td>", (row["region"].ToString().IndexOf(",") != -1) ? row["region"].ToString().Split(new char[] { ',' }).GetValue(0) : row["region"].ToString(), (row["region"].ToString().IndexOf(",") != -1) ? row["region"].ToString().Split(new char[] { ',' }).GetValue(1) : "", row["address"], "</td>" }));
                    builder.AppendLine("<td>" + row["zipcode"] + "</td>");
                    builder.AppendLine("<td>" + row["mobile"] + "</td>");
                    builder.AppendLine("<td>" + row["telephone"] + "</td>");
                    builder.AppendLine("</tr>");
                }
                builder.AppendLine("</table>");
            }
        }
        catch
        {
        }
        return builder;
    }

}